<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('开卡')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-openRecord-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">业务号VID：</label>
                <div class="col-sm-8">
                    <select name="vid" class="form-control m-b" th:with="type=${@dict.getType('vid_group_list')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">开卡数量：</label>
                <div class="col-sm-8">
                    <input name="number" class="form-control" type="text" value="1">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所属分组：</label>
                <div class="col-sm-8">
                    <select name="groupName" class="form-control m-b" th:with="type=${@dict.getType('card_group_list')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">卡片名称：</label>
                <div class="col-sm-8">
                    <input name="cardName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "card/openRecord"
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#form-openRecord-add").validate({
            focusCleanup: true,
            rules: {
                number: {
                    required: true,
                    digits: true,
                    max: 5,
                    min: 1
                },
                cardName: {
                    required: true,
                    minlength: 2
                }
            },
            messages: {
                number: {
                    required: icon + "请输入开卡数量",
                    digits: icon + "只能输入数字",
                    max: icon + "最大开卡数量5",
                    min: icon + "最小开卡数量1"
                },
                cardName: icon + "请输入开卡名称"
            }
        });


        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-openRecord-add').serialize());
            }
        }
    </script>
</body>
</html>